<%@ page language="java" contentType="text/html; charset=UTF-8"
		 pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<title>配置系统</title>
	<jsp:include page="common/common_head.jsp"></jsp:include>

	<link rel="stylesheet" href="../codemirror-4.10/lib/codemirror.css">
	<link rel="stylesheet" href="../codemirror-4.10/addon/display/fullscreen.css">
	<link rel="stylesheet" href="../codemirror-4.10/theme/midnight.css">
	<link rel="stylesheet" href="../codemirror-4.10/theme/eclipse.css">

	<link rel="stylesheet" href="../codemirror-4.10/addon/dialog/dialog.css">
	<link rel="stylesheet" href="../codemirror-4.10/addon/search/matchesonscrollbar.css">

	<script src="../codemirror-4.10/lib/codemirror.js"></script>
	<script src="../codemirror-4.10/mode/${js}"></script>


	<link rel="stylesheet" href="../codemirror-4.10/addon/hint/show-hint.css" />
	<script src="../codemirror-4.10/addon/hint/show-hint.js"></script>
	<script src="../codemirror-4.10/addon/display/fullscreen.js"></script>
	<script src="../codemirror-4.10/addon/selection/active-line.js"></script>

	<script src="../codemirror-4.10/keymap/sublime.js"></script>

	<script src="../codemirror-4.10/addon/dialog/dialog.js"></script>
	<script src="../codemirror-4.10/addon/search/searchcursor.js"></script>
	<script src="../codemirror-4.10/addon/search/search.js"></script>
	<script src="../codemirror-4.10/addon/scroll/annotatescrollbar.js"></script>
	<script src="../codemirror-4.10/addon/search/matchesonscrollbar.js"></script>


	<style type="text/css">
		body {line-height: 1}
		th {text-decoration: "auto"}
	</style>
</head>
<body  data-spy="scroll" data-target=".navbar">



<jsp:include page="common/common_banner_app.jsp"></jsp:include>
<div style="height:30px"></div>
<div class="container" style="height: 1000px">



				<div  class="control-group" style="margin-bottom: -3px;margin-top: 5px;">

					<c:if test="${!readonly}">
						<div class="input-prepend">
							<span class="add-on">路径</span>
							<input type="text" placeholder="路径" value = "${path}" id="path">
						</div>
						<div class="input-prepend">
							<span class="add-on">版本</span>
							<input type="text" name="version" placeholder="版本" value = "${version}"  id="version">
						</div>

						<div class="input-prepend">
							<span class="add-on">说明</span>
							<input type="text" name="date" placeholder="说明" value = "${comment}"  id="comment">
						</div>

						<div class="input-prepend">
							<button type="button" onclick="addVersion()" class="btn" >提交</button>
						</div>
					</c:if>
				</div>

				<div>
					<textarea style="width : 100%; height : 1000px" name = "conf" id="sql">${conf}</textarea>
					<input type="hidden" name="path" value="${path}">

				</div>

</div>






	<jsp:include page="common/common_js.jsp"></jsp:include>


	<script>



		var editor = null


		$(document).ready(function(){
			editor = CodeMirror.fromTextArea(document.getElementById("sql"), {
				mode: "${type}",
				indentWithTabs: true,
				smartIndent: true,
				lineNumbers: true,
				matchBrackets : true,
				autofocus: true,
				height: "1000",
				lines: 300,
				theme: "eclipse",
				styleActiveLine: true,
				extraKeys: {
					"Ctrl-.": "autocomplete",
					"Ctrl-Enter": function(){search()},
					"F11": function(cm) {
						if(cm.getOption("fullScreen")){
							$(".navbar").css("display", "");
							cm.setOption("theme", "eclipse");

						}else{
							cm.setOption("theme", "midnight");
							$(".navbar").css("display", "none")

						}
						cm.setOption("fullScreen", !cm.getOption("fullScreen"));

					}

				},
				hintOptions: {tables: {
					users: {name: null, score: null, birthDate: null},
					countries: {name: null, population: null, size: null}
				}}
			});

		})

		function addVersion(){
			$.ajax({
				url: "../conf/addConf.html",
				type: "POST",
				data: {"conf": editor.doc.getValue(), "path": "${path}", "version": $("#version").val(), "comment": $("#comment").val()},
				dataType: "json",
				success: function(r){
					if(r.result == "success"){
						//alert("添加成功!")
						location.href="http://" +location.host + "/conf/versionList.html?path=${path}"
					}else{
						alert(r.result);
					}
				}
			})
		}
	</script>
</body>
</html>